module top(

//input clk_sys, 
input clk,
input rst,
input keyopen,
input [4:0] keyin,
input [3:0] keyoutup,
input [4:0] keyoutdown,

output [4:0] ledin,
output [3:0] ledoutup,
output [3:0] ledoutdown,
output beep,
output [6:0] segfloor,
output [6:0] segupdown,
output [6:0] segdoor,

output lineL1,
output lineL2

);

wire clk1;
divclk divclk(
	.clk(clk),
	.rst_n(rst),
	.clk_div(clk1)

); 


wire [4:0] inreq;
wire [4:0] outrequp;
wire [4:0] outreqdown;
wire [4:0] cur_floor;
wire up;
wire down;
wire stop;
wire [4:0] inreqN;
wire [4:0] outreqUN;
wire [4:0] outreqDN;


get_request get_request(
	.in_reqnew(inreqN),
	.out_requpnew(outreqUN),
	.out_reqdownnew(outreqDN),
	
	.keyL(keyin),
	.out_keyup(keyoutup),
	.out_keydown(keyoutdown),
	
	.in_req(inreq),
	.out_requp(outrequp),
	.out_reqdown(outreqdown)
	
	
);

elevator elevator(
	.clk(clk),
	.rst(rst),
	.in_req(inreq),
	.out_requp(outrequp),
	.out_reqdown(outreqdown),
	.key_open(keyopen),
	
	.clk1(clk1),
	
	.cur_floor(cur_floor),
	.up(up),					
	.down(down),				
	.stop(stop),
	.in_reqN(inreqN),
	.out_requpN(outreqUN),
	.out_reqdownN(outreqDN)
);



led led(
	.in_req(inreq),
	.out_requp(outrequp),
	.out_reqdown(outreqdown),

	.ledup(ledoutup),
	.leddown(ledoutdown),
	.ledinL(ledin)
	
);



seg segL(
	.cur_f(cur_floor),
	.up(up),
	.down(down),
	.stop(stop),
	.dis_cur(segfloor),
	.direc(segupdown),
	.disdoor(segdoor)
);



assign beep = stop;


dianji left(
	.up(up),
	.down(down),
	.stop(stop),
	.line1(lineL1),
	.line2(lineL2)
);



endmodule
